package com.yoda.mall.admin.controller;

import com.yoda.mall.admin.service.OrderReturnReasonService;
import com.yoda.mall.model.entity.oms.OrderReturnReason;
import com.yoda.mall.model.entity.sms.FlashPromotionSession;
import com.yoda.mall.model.entity.sms.HomeAdvertise;
import com.yoda.mall.model.vo.FlashPromotionSessionVo;
import com.yoda.mall.model.vo.PageResult;
import com.yoda.mall.model.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("returnReason")
public class OrderReturnReasonController {
    @Autowired
    private OrderReturnReasonService orderReturnReasonService;

    //添加退货原因
    @PostMapping("create")
    public R createOrderReturnReason(@RequestBody OrderReturnReason orderReturnReason){
        orderReturnReasonService.createOrderReturnReason(orderReturnReason);
        return R.success();
    }

    //批量删除退货原因
    @PostMapping("delete")
    public R deleteOrderReturnReason(@RequestParam List<Long> ids){
        orderReturnReasonService.deleteOrderReturnReason(ids);
        return R.success();
    }

    //分页查询退货原因
    @GetMapping("list")
    public R orderReturnReasonList(Integer pageNum, Integer pageSize){
        PageResult<OrderReturnReason> pageResult = orderReturnReasonService.orderReturnReasonList(pageNum,pageSize);
        return R.success(pageResult);
    }

    //修改退货原因启用状态
    @PostMapping("update/status")
    public R updateOrderReturnReasonStatus(Integer status,@RequestParam List<Long> ids){
        orderReturnReasonService.updateOrderReturnReasonStatus(ids,status);
        return R.success();
    }

    //修改退货原因
    @PostMapping("update/{id}")
    public R updateOrderReturnReason(@RequestBody OrderReturnReason orderReturnReason,@PathVariable Long id){
        orderReturnReasonService.updateOrderReturnReason(id,orderReturnReason);
        return R.success();
    }

    //获取单个退货原因详情信息
    @GetMapping("{id}")
    public R getOrderReturnReason(@PathVariable Long id){
        OrderReturnReason orderReturnReason = orderReturnReasonService.getOrderReturnReason(id);
        return R.success(orderReturnReason);
    }
}
